package everydayGrade.t5;

import org.junit.jupiter.api.Test;

/**
 * @Author: Siantar
 * @Date: 2023-12-03-18:12
 * @Description: 1.0
 */
public class T1423 {
    public int maxScore(int[] cardPoints, int k) {
        int n = cardPoints.length;
        int t = n - k;
        int min = Integer.MAX_VALUE;
        int i = 0, leftSum = 0, rightSum = 0;
        while (i < n) {
            System.out.println("i:"+i);
            System.out.println("t:"+t);
            while (i < t - 1) {
                leftSum += cardPoints[i];
                i++;
            }
            leftSum += cardPoints[i];
            min = Math.min(min, leftSum - rightSum);
            rightSum += cardPoints[i - t + 1];
            i++;
        }
        return leftSum - min;
    }

    @Test
    public void test() {
        System.out.println(maxScore(new int[]{1, 2, 3, 4, 5, 6, 1}, 3));
        for (int i = 03; i < 7; i++) {

        }
    }

}

